/*
 *  $Id: $
 *
 *  Part of INX: INterfaces in Xml.
 *  Copyright (C) 2007 David Griffiths
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
package dg.inx;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

public abstract class AbstractModel {
    private PropertyChangeSupport pcs = new PropertyChangeSupport(this);

    public final void addPropertyChangeListener(
            final PropertyChangeListener listener
            ) {
        pcs.addPropertyChangeListener(listener);
    }

    public final void removePropertyChangeListener(
            final PropertyChangeListener listener
            ) {
        pcs.removePropertyChangeListener(listener);
    }

    public final synchronized void addPropertyChangeListener(
            final String propertyName,
            final PropertyChangeListener listener
            ) {
        pcs.addPropertyChangeListener(propertyName, listener);
    }

    public final synchronized void removePropertyChangeListener(
            final String propertyName,
            final PropertyChangeListener listener
            ) {
        pcs.removePropertyChangeListener(propertyName, listener);
    }

    protected final void firePropertyChange(final String propertyName,
            final Object oldValue, final Object newValue) {
        pcs.firePropertyChange(propertyName, oldValue, newValue);
    }

    protected final void firePropertyChange(final String propertyName,
            final int oldValue, final int newValue) {
        pcs.firePropertyChange(propertyName, oldValue, newValue);
    }
}
